#region

using System.ComponentModel.DataAnnotations;
using Microsoft.AspNetCore.Mvc;
using Vin.Extension.Framework.Aop;
using Vin.Extension.Framework.Base;
using Vin.Extension.Framework.Monitor.Dto.List;
using Vin.Extension.Framework.Monitor.ServiceInterface;
using Vin.Tool.Attributes;

#endregion

namespace Vin.Extension.Framework.Monitor.Controller.Controllers;

[Route("monitor/operate-log")]
public class SysOperateLogController : VinFrameworkBaseController
{
    [Inject] private readonly ISysOperateLogService _sysOperateLogService = null!;

    [VinAuthorize("monitor:operate-log:list"), HttpGet("list")]
    public async Task<IActionResult> List([FromQuery] SysOperateLogListDto dto)
    {
        return Success(await _sysOperateLogService.ListAsync(dto), dto.TotalCount);
    }

    [VinAuthorize("monitor:operate-log:query"), HttpGet("query")]
    public async Task<IActionResult> Query([Required(ErrorMessage = "操作记录不能为空")] long id)
    {
        return Success(await _sysOperateLogService.QueryAsync(id));
    }

    [VinAuthorize, HttpGet("user")]
    public async Task<IActionResult> UserList([FromQuery] SysOperateLogListDto dto)
    {
        dto.AccountId = AccountId;
        return Success(await _sysOperateLogService.ListAsync(dto), dto.TotalCount);
    }
    
    [VinAuthorize, HttpGet("employee")]
    public async Task<IActionResult> EmployeeList([FromQuery] SysOperateLogListDto dto)
    {
        dto.UserId = UserId;
        return Success(await _sysOperateLogService.ListAsync(dto), dto.TotalCount);
    }
}